package test.my.com.myapplicationtest.retrofit_net;

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;


import rx.subscriptions.CompositeSubscription;

/**
 * Author : Cooper
 * Time : 2017/8/29  17:00
 * Description :
 */

public class RetrofitBaseActivity extends Activity {

    protected CompositeSubscription mCompositeSubscription;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mCompositeSubscription = new CompositeSubscription();
    }

    //RXjava取消注册，以避免内存泄露
    private void onUnsubscribe() {
        if (mCompositeSubscription != null && mCompositeSubscription.hasSubscriptions()) {
            mCompositeSubscription.unsubscribe();
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        onUnsubscribe();
    }
}
